<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    const arr1 = [1, 10, 8, 9, 3];
    arr1.forEach((e, i) => {
        console.log(e, i);
    });
    //遍历数组中的值只要有一个值满足条件就返回true
    const arr2 = ['a', 'a', 'a', 'a'];
    var res = arr2.some((e) => e === 'e')
    console.log(res);
    //遍历数组中的值每一个值满足条件就返回true
    var res1 = arr2.every((e) => {
        return e === 'a';
    })
    console.log(res1);
    var res2 = arr1.filter((e) => e >= 8);
    console.log(res2);
    let amt = 10;
    var totalAmt = arr1.reduce((per, cur) => {
        console.log('per' + per);
        console.log('cur' + cur);
        return per + cur;
    }, amt);
    console.log(totalAmt);

    var goodsList = [{
        name: 'iphone7',
        price: 2000,
        num: 3,
        fal: true
    }, {
        name: 'sanxing',
        price: 2100,
        num: 1,
        fal: false
    }, {
        name: 'xiaomi',
        price: 1500,
        num: 2,
        fal: true
    }, {
        name: 'huawei',
        price: 1000,
        num: 1,
        fal: false
    }]
    var goods1 = goodsList.find((e) => {
        return e.name === 'xiaomi'
    });
    console.log(goods1);
    var xiaomis = goodsList.filter((e) => e.name === 'xiaomi');
    console.log(xiaomis);
    var totalSum = goodsList.filter((e) => e.fal === true).reduce((per, cur) => {
        return per += cur.price * cur.num;
    }, 10)
    console.log(totalSum);
</script>

</html>